<template>
<div>
  	<div class="dizhi">
  		<router-link to="/shdz1">
			<flexbox :gutter="0">
				<flexbox-item :span="1/7">
					<div class="flex-demo">
						<!-- <div style="display: table;margin:0 auto;"> -->
							<img src="static/address.png">
						<!-- </div> -->
					</div>
				</flexbox-item>
				<flexbox-item :span="5/7" v-show="!wudizhi">
					<div class="flex-demo">
						<div style="display: table;">
				  			<div class="shr">{{address.username}}</div>
				  			<div class="sh_dh">{{address.phone}}</div>
				  		</div>
			  			<div class="sh_dz">{{address.areaid_1}}{{address.areaid_2}}{{address.areaid_3}}{{address.address}}</div>
					</div>
				</flexbox-item>
				<flexbox-item :span="5/7" v-show="wudizhi">
					<div class="flex-demo">
						<div style="display: table;">
				  			<div style="font-size: 14px;line-height: 40px;color: #333;">添加收货地址</div>
				  		</div>
					</div>
				</flexbox-item>
				<flexbox-item :span="1/7">
					<div class="flex-demo">
						<div style="display: table;position: relative;width: 100%;">
							<img src="static/arrow_right_gray.png" style="position: absolute;right: 0;top:-5px;">
						</div>
					</div>
				</flexbox-item>
			</flexbox>
		</router-link>
		<div class="dz_line">
		  	<img src="static/huawen.jpg"/>
		</div>
  	</div>
	<div style="width: 100%; height: 10px;background-color: #eee;"></div>
	<div v-show="!zanwu" style="width: 100%;margin-top: 80px;"><p style="font-size: 14px;line-height: 20px;text-align: center;">暂无信息</p></div>
  	<!-- 此处循环 -->
  	<div v-for="value in list" v-show="zanwu">
	  	<div style="background-color: #ffffff;display: table;width: 100%;">
	  		<div class="ji_fenk1">
				  	<ul>
				  		<li class="tu2_tu22"></li>
				  		<li class="jifenshangcheng">积分商城</li>
				  		<div class="clearfix"></div>
				  	</ul>
		  		</div>
		  	<router-link :to="{path:'/jifenshangpingxiangqing',query:{id:value.goods_id}}">
			  	<div class="tu1_box1">
			  		<div class="tu1_tu11">
				  		<div class="tupianone">
				  			<img :src="url + value.goodsImg" style="width: 100%;height: 100%;">
				  		</div>
				  		<div class="wenzi">
					  		<p style="font-size: 13px;color: #4a4a4a;line-height: 16px;height: 32px;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp:2;overflow: hidden;">{{value.goodsName}}</p>
					  		<p style="font-size: 12px;color: #9b9b9b;line-height: 12px;margin-top: 5px;">{{value.shuxing}}</p>
					  		<p style="line-height: 13px;font-size: 14px;color: #4A4A4A;margin-top: 9px;float: left;">{{value.jifen}}积分</p>
					  		<p class="cheng_1">x {{value.num}}</p>
				  		</div>
			  		</div>
			  	</div>
			</router-link>
		  	<div class="yu_fei">
		  		<span class="yun_fei">运费</span>
		  		<span class="ji_fen">{{value.postage}} 积分</span>
		  	</div>
		  	<div class="yu_fei">
		  		<span class="sanqi">{{value.zongjifen}} 积分</span>
		  		
		  		<span class="gongyi">共{{value.num}}件商品 小计：</span>
		  	</div>
		</div>
		<div style="width: 100%; height: 10px;background-color: #eee;"></div>
	</div>
	<div style="width: 100%;height:50px;"></div>
	<!-- 此处循环结束 -->
   	<div class="tjdd_footer">
	   	<div class="heji_zuo">
	   		<span class="heji_jine">{{countjifen}} 积分</span>
	   		<span class="heji_text">合计：</span>
	   		<div class="clearfix"></div>
	   	</div>
	   	<!-- <router-link to="/yhcg"> -->
		   	<div class="tjdd_btnone" @click="duihuan" v-show="zanwu">
		   		<p style="font-size: 14px;line-height: 50px;text-align: center;color: #fff;">去兑换</p>
		   	</div>
		   	<div class="tjdd_btnone" v-show="!zanwu" @click="wuxinxi">
		   		<p style="font-size: 14px;line-height: 50px;text-align: center;color: #fff;">去兑换</p>
		   	</div>
	   	<!-- </router-link> -->
   	</div>
   	<toast v-model="show" type="text" :time="1500" position="middle">{{tishi}}</toast>
   	<loading :show="show2" :text="text1"></loading>
</div>
</template>

<script>
//import { Group, Cell } from 'vux'
import { Group, XNumber, XSwitch, Divider } from 'vux'
import { Flexbox, FlexboxItem } from 'vux'
import axios from 'axios'
import { mapState, mapActions } from 'vuex'
export default {
	components: {
		XNumber,
		Group,
		XSwitch,
		Divider,
		Flexbox, 
		FlexboxItem,
		mapState, 
		mapActions
	},
	data () {
		return {
			roundValue: 0,
			address:'',
			countjifen:'',
			list:'',
			show:false,
			tishi:'',
			zanwu:true,
			wudizhi:false,
			show2:false,
			text1:'Loading...',
			goods_id:'',
			goods_attr_id:'',
			name:'',
			canshu:'',
			goods_id2:'',
			goods_attr_id2:'',	
		}
	},
	methods: {
		change (val) {
			console.log('change', val)
		},
		wuxinxi(){
			this.show = true;
			this.tishi = '暂无信息';
		},
		duihuan(){
			var that = this;
			axios.post(that.url+"/home/JifenOrder/order_add",{openid:this.token,countjifen:this.countjifen,canshu:this.canshu,goods_id:this.goods_id2,goods_attr_id:this.goods_attr_id2})
	        .then(function(res){
	        	console.log(res)
	        	if(res.data.status == 1){
	        		that.show = true;
	        		that.tishi = '兑换成功';
	        		setTimeout(()=>{
	        			that.$router.push({path:'/yhcg',query:{status:res.data.status,becau:res.data.msg,order_id:res.data.order_id}})
	        		},2000)
	        	}else if(res.data.status == -2 || res.data.status == -1){
	        		that.show = true;
	        		that.tishi = res.data.msg;
	        		setTimeout(()=>{
	        			that.$router.push({path:'/yhcg',query:{status:res.data.status,becau:res.data.msg,order_id:res.data.order_id}})
	        		},2000)
	        	}
	        	else{
	        		that.show = true;
	        		that.tishi = '兑换失败';
	        		setTimeout(()=>{
	        			that.$router.push({path:'/yhcg',query:{status:res.data.status,becau:res.data.msg,order_id:res.data.order_id}})
	        		},2000)
	        	}
	        })
	        .catch(function(err){
	            console.log(err);
	        })
		},
	},
	created(){
		this.show2 = true;
		this.goods_id = this.$route.query.goods_id;
		this.goods_attr_id = this.$route.query.goods_attr_id;
		this.name = this.$route.query.name;
		if(this.$route.query.panduan == 0){
			this.noadd = 0;
		}else{
			this.noadd = '';
		}
		
		var that = this;
		axios.post(that.url+"/home/JifenOrder/getOrdersSure",{openid:this.token,goods_id:this.goods_id,goods_attr_id:this.goods_attr_id,name:this.name,noadd:this.noadd})
        .then(function(res){
        	console.log(res)
        	if(res.data.address == 0){
        		that.wudizhi = true;
        	}else{
        		that.wudizhi = false;
        		that.address = res.data.address;
        	}
        	that.countjifen = res.data.countjifen;
        	if(res.data.info == null || !res.data.info || res.data.info == ''){
        		that.zanwu = false;
        	}else{
        		that.list = res.data.info;
        	}
        	that.show2 = false;
        	if(res.data.canshu == 0){
        		that.canshu = res.data.canshu;
        		that.goods_id2 = res.data.info[0].goods_id;
        		that.goods_attr_id2 = res.data.info[0].goods_attr_id;
        	}else{
        		that.canshu = ''
        	}
        })
        .catch(function(err){
            console.log(err);
        })
	},
  	computed:{
        ...mapState({
            token: state => state.Token.userToken()//获取用户Token
        }),
    }
}

</script>

<style scoped>
	
	*{
		/*box-sizing: border-box;*/
	}
	body{
		position: relative;
	}
	.weui-cell{
		padding: 0px 15px;
	}
	input{
		margin: 0;
		padding: 0;
		display: block;
		outline: none;
	}
	.tjdd_footer{
		width: 100%;
		height: 50px;
		position: fixed;
		bottom: 0;
		background: #FFFFFF;
		border: 1px solid #eeeeee;
	}
	.heji_jine{
		float: right;
		height: 50px;
		line-height: 50px;
		font-family: "微软雅黑";
		color: #DF3033;
		font-size: 14px;
		padding-right: 3px;
		font-size: 14px;
		background-color: #FFFFFF;
	}
	.heji_text{
		float: right;
		height: 50px;
		line-height: 50px;
		color: #333333;
		background-color: #FFFFFF;
		font-size: 14px;
		
		
	}
	.tjdd_btnone{
		width: 30%;
		float: left;
		/*border: 1px solid black;
		box-sizing: border-box;*/
		height: 50px;
		background-color: #00C850;
	}
	.tjdd_btn input{
		width: 100%;
		line-height: 50px;
		background-color: #00C850;
		color: #fff;
		font-size: 16px;
		outline: none;
		border:none ;
	}
	.heji_zuo{
		width: 70%;
		height: 50px;
		float: left;
		background-color: #FFFFFF;
	}
	.sp_xj{
		margin-right: 16px;
	}
	.spxj{
		float:right;
		color: #333333;
		font-size: 15px;
	}
	.xj_jine{
		float: right;
		color: #DF3033;
		font-size: 15px;
		font-family: "微软雅黑";
	}
	.weui-cells {
    background-color: #FFFFFF;
    line-height: 1.41176471;
    font-size: 14px;
    overflow: hidden;
    position: relative;
}
	.clearfix{
		clear: both;
	}
	.cz_number{
		border-bottom: 1px solid #E5E5E5;
		width: 92%;
		margin: 0 auto;
	}
	.chongzhihaoma{
		width: 20%;
		margin: 14px 0;
		font-size: 16px;
		float: left;
	}
	.shuru{
		padding: 0 5px;
		height: 25px;
		width: calc(80% - 10px);
		font-size: 16px;
		margin: 14px 0;
		float: left;
	}
	.dizhi{
		width: 100%;
		margin: 0 auto;
		padding: 0 15px;
		display: table;
		background-color: #ffffff;
	}
	.dz_tp{
		/*background: url(../assets/img/address.png)no-repeat center;*/
		background-size: 28px;
		float: left;
		height: 114px;
		width: 10%;
		margin-top: 0px;
		height: 70px;
	}
	img,input{
		display: block;
	}
	
	.qr_xx{
		width: 80%;
		
		float: left;
		margin-top: 20px;
		/*margin-left: 10px;*/
		
	}
	.shr{
		color: #333333;
		font-size: 14px;
		float: left;
		line-height: 14px;
		margin-top:10px;
	}
	.sh_dz{
		color: #9B9B9B;
		font-size: 13px;
		line-height: 17px;
		margin-top:5px;
		margin-bottom:5px;
	}
	.sh_dh{
		float: left;
		margin-left: 10px;
		color: #333333;
		font-size: 14px;
		line-height: 14px;
		margin-top:10px;
	}
	.yjt{
		
		height: 78px;
		float: right;
		/*background: url(../assets/yjt.png) no-repeat center;*/
		background-size: 7px;
		
		
	}
	.yjt img{
		display: block;
		height: 20px;
		width:20px;
		margin-top: 30px;
		
		
	}
	.dz_line{
		width: 100%;
		height: 2px;
	}
	.dz_line img{
		display: block;
		height: 2px;
		width: 100%;
	}
	.zgydgfqjd{
		width: 100%;
		font-size: 12px;
		color: #333333;
		margin: 10px 0;
	}
	.zg_wenzi{
		margin: 11px 0px 10px 16px;
	}
	.spxq_spnr{
		width: 100%;
		height: 78px;
		padding: 15px 0;
		/*border: 1px solid red;*/
		background-color: #fafafa;
		
	}
	.sp_xtp{
		width: 78px;
		height: 78px;
		/*border: 1px red solid;*/
		margin-left: 15px;
		float: left;
	}
	.sp_xtp img{
		width: 100%;
		display: block;
	}
	.spnr_wenzi{
		height: 78px;
		float: right;
		background-color: #FAFAFA;
		box-sizing: border-box;
		/*border: 1px solid black;*/
		position: relative;
		width: calc(100% - 108px);
		padding-right: 27px;
	}
	.spnr_text{
		font-size: 14px;
		color: #333333;
		background-color: #FAFAFA;
	}
	.sp_jt_jg{
		font-size: 16px;
		color: #DF3033;
		background-color: #FAFAFA;
	}
	.jine{
		float: left;
		font-family: "微软雅黑"
	}
	.shuliang{
		float: right;
		color: #333333;
		font-size: 12px;
		position: absolute;
		bottom: 0;
		right: 27px;
	}
	input::-webkit-input-placeholder{
		color: #949494;
		font-size: 16px;
	}
	.content1{
		width: 100%;
		border: 1px /*solid*/ red;
		color: white;
		/*border: 1px solid red;*/
	}
	
.zl{
		width: 100%;
		text-align: center;
		line-height: 20px;
		font-size: 16px;
		margin-top: 15px;
		color: #333;
	}
.gzjf{width: 100%;
		text-align: center;
		line-height: 17px;
		font-size: 13px;
		color: #7f7f7f;
		margin-top: 10px;
		padding: 0 15px;
		
	}
.lan{
		width: 100%;
		border: 1px /*solid*/ green;
		margin-top: 20px;
	}
.yq{margin: 0 auto;
		width: 100%;
		height: 44px;
		background-color: #00c850;
		color: #FFFFFF;
		line-height: 22px;
	}
.lan1{
		float: left;
		width: 100%;
		border: 1px /*solid */green;
		
		line-height: 13px;
		font-size: 13px;
		color: #333;
		margin-left: 301px;
		margin-bottom: 20px;
	}
.yq1{
		padding: 0 20px;
		width: 100%;
		height: 44px;
		background-color: white;
		color: #00C850;
		line-height: 22px;
	}
	
*{list-style: none;margin: 0;padding: 0;}
.pq li{color: #333;
	       float: left;
	       line-height: 20px;
	       font-size: 14px;
	       margin-top: 10PX;
}
.pq .tu{height: 24px;
		width: 24px;
		border-radius: 50%;
		border: 1px /*solid*/ black;
		margin: 0 3px;
		margin-top: 8PX;
		}

.pq .pqz{float: right;
		color: #7f7f7f;
		line-height: 14px;
	    font-size: 13px;
	    /*margin-top: 13PX;*/
		}
.er_er{float: right;
		color: #333;
		line-height: 18px;
	    font-size: 16px;
	    margin-top: 6px;
}
.j_f{float: right;
		color: #333;
		line-height: 17px;
	    font-size: 12px;
	    margin-top: 6px;
		
}	
.you_fei{float: right;
		color: #333;
		line-height: 17px;
	    font-size: 12px;
		margin-top: 6px;
}	
.wenzi{margin-left:10px;
		float: right;
		box-sizing: border-box;
		border: /*solid*/ yellow 1px;
		width: calc(100% - 85px);
		
		}
.di{margin: 0;
			box-sizing: border-box;
			border: /*solid*/ 1PX slateblue;
			padding: 0 15px;
			}
.hyzl{float: right;
		background: #9b9b9b;
		height: 12px;
		width: 12px;
		margin-top: 5px;
		}
.ds_pqgz{margin-top: 6px;
			font-size: 12px;
			color: #333;
			float: right;
			line-height: 17px;
			}

.clearfix{float: none;
	clear: both;
	}

.tu1_box1{
	border: 1px solid red;
	border-bottom: 1px solid red;
	border: 1px /*solid*/ black;
	padding: 12px 0px;
	width: 100%;
	display: table;
}			
.tupianone{
	height: 75px;
	width: 75px;
	float: left;
	/*background: url(../assets/img/Rectangle 26.png) no-repeat center;*/
}	
.ji_fenk1{
	border-bottom: 1px solid #EEEEEE;
	padding: 10px 10px;
	border: 1px /*solid*/ red;
	padding: 0 15px;
}
.jifenshangcheng{
	float: left;
	line-height: 20px;
	font-size: 14px;
	margin-left: 10px;
	margin-top: 10px
}
.yifahuo{
	float: right;
	line-height: 20px;
	font-size: 14px;
	color: #FF2E22;
	margin-top: 10px;
	margin-right: -7px;
	
	
	
}
.ji_fenk1 .tu2_tu22{
	width: 24px;
	height: 24px;
	border: 1px /*solid*/ red;
	float: left;
	background-size: 24px;
	margin-top: 8px;
	margin-left: -12px;
	padding: 0 20px;
	
}
.tu1_tu11{
	border: 1px /*solid*/ red;
	margin-top: 0px;
	padding: 0 15px;
}
.cheng_1{
	float: right;
	margin-top: 10px;
	line-height: 13px;
	font-size: 13PX;
	color: #4A4A4A;
}
.yu_fei{
	width: 100%;
	height: 44px;
	padding: 0 15px;
	border-top: 1px solid #EEEEEE;
	
}
.yun_fei{
	float: left;
	line-height: 20px;
	font-size: 14px;
	color: #333333;
	margin-top: 12px;
}
.ji_fen{
	float: right;
	line-height: 20px;
	font-size: 14px;
	color: #333333;
	margin-top: 12px;
}
.sanqi{
	float: right;
	line-height: 20px;
	font-size: 14px;
	color: red;
	margin-top: 12px;
}
.gongyi{
	float: right;
	line-height: 20px;
	font-size: 14px;
	color: #333333;
	margin-top: 12px;
}
</style>
